<?php
/**
 * --------------------------------------------------------------------
 * MCore框架
 * 作者：阿枫，QQ：52037872，Email：nczy520@gmail.com
 * --------------------------------------------------------------------
 *
 * SVN revision information:
 * @version $Revision: 50 $:
 * @author  $Author: zy $:
 * @date      $Date: 2013-11-09 19:34:15 +0800 (星期六, 09 十一月 2013) $:
 * @url         $HeadURL: svn://vps.mdeve.com/web_mcore/manage/function/global.func.php $:
 */

class _LoginClass extends __basic_def {

    function _welcome() {
        global $_M, $template;

        $template = MANAGE_PATH."/templates/login/welcome";
        if($_M->cfg["module_enable"]) module_insert_code('manage_welcome_load_template');

        $_M->template();
        $_M->template->load($template);
        if($_M->cfg["module_enable"]) module_insert_code('manage_welcome_proc_template');
        $_M->template->display();
    }

    function _submit(){
        global $_M, $user, $pass, $save;

        $user = clear_string(filter_input(INPUT_POST, "user"));
        $pass = clear_string(filter_input(INPUT_POST, "pass"));
        $save = intval(filter_input(INPUT_POST, "save"));

        if($_M->cfg["module_enable"]) module_insert_code('manage_login_submit');

        $result = $_M->user->login($user, $pass, "?", $save);

        if($result === true) {
            ajax_result("successful");
        } else {
            ajax_result("error", $result);
        }
    }

    function _out(){
        global $_M;

        if($_M->cfg["module_enable"]) module_insert_code('manage_login_out');

        $_M->user();
        $_M->user->logout();

        javascript_result("window.location.href='/manage';");
    }

}